use serde::{Serialize,Deserialize};
use std::collections::HashMap;

#[serde(default,rename_all = "camelCase")]
#[derive(Default,Serialize,Deserialize)]
pub struct Ticket{
    pub my_name:String,
    my_age:i32,
    #[serde(skip_serializing_if = "Option::is_none")]
    my_self:Option<Box<Ticket>>,
    #[serde(flatten)]
    size:Size,
}
#[serde(default)]
#[derive(Default,Serialize,Deserialize)]
pub struct Size{
    limit:usize,
    offset:usize,
    #[serde(rename = "Total")]
    total:usize,
}
#[tokio::main]
async fn main() {
    let json = serde_json::json!({
        "myName":"我是好人",
        "myAge":22,
        "limit":10,
        "mySelf":{
            "offset":20
        }
    });
    let ticket = serde_json::from_value::<Ticket>(json).unwrap();
    let res = serde_json::to_string(&ticket).unwrap_or_else(|e|e.to_string());
    println!("json:{}",res);
}